import { request } from "./request";
/**
 * 
 * @param method 以GET,POST为例，需要其他请求方法的自行修改
 * @param data 一个json对象参数
 * @param header 自定的header，与默认重复的key将覆盖默认的header设置
 */

//登录接口，根据业务替换为真实的请求路径  默认参数传递 为 {code:wxCode}  如有必要可在utils/login.js => refreshLogin 方法中更改
export const login = (data, header) => request({ method: 'POST', url: '/api/weapp/user/login', identity: false, data, header });

//GET 获取用户信息
export const getUserInfo = (data, header) => request({ method: 'GET', url: '/api/weapp/user/getUserInfo', identity: true, data, header });

// 绑定用户信息
export const bindUserInfo = (data, header) => request({ method: 'POST', url: '/api/weapp/user/bindUserInfo', identity: false, data, header });


// 商品模块
//GET 获取一级商品分类
export const getGoodsTypeByPid = (data, header) => request({ method: 'GET', url: '/api/weapp/goods/getGoodsTypeByPid', identity: true, data, header });

//GET 获取商品列表 推荐值排序
export const getGoodsList = (data, header) => request({ method: 'GET', url: '/api/weapp/goods/getGoodsList', identity: true, data, header });

//GET 获取商品列表 根据type查 推荐值排序
export const getGoodsListByType = (data, header) => request({ method: 'GET', url: '/api/weapp/goods/getGoodsListByType', identity: true, data, header });

//GET 获取商品详情
export const getGoodsDetails = (data, header) => request({ method: 'GET', url: '/api/weapp/goods/getGoodsDetails', identity: true, data, header });

// 首页轮播
//GET 获取轮播
export const getSwiperList = (data, header) => request({ method: 'GET', url: '/api/weapp/operate/getSwiperList', identity: true, data, header });


// 收藏
//GET 获取所有收藏
export const getCollectList = (data, header) => request({ method: 'GET', url: '/api/weapp/operate/getCollectList', identity: true, data, header });

//POST 添加收藏
export const addCollect = (data, header) => request({ method: 'POST', url: '/api/weapp/operate/addCollect', identity: true, data, header });

//POST 取消收藏
export const delCollect = (data, header) => request({ method: 'POST', url: '/api/weapp/operate/delCollect', identity: true, data, header });


//POST 添加、增加数量、删除 购物车
export const changeCart = (data, header) => request({ method: 'POST', url: '/api/weapp/operate/changeCart', identity: true, data, header });
// 获取购物车列表
export const getCartList = (data, header) => request({ method: 'GET', url: '/api/weapp/operate/getCartList', identity: true, data, header });


// 收货地址
//GET 获取所有收货地址
export const getAddress = (data, header) => request({ method: 'GET', url: '/api/weapp/user/getAddress', identity: true, data, header });

//POST 添加收货地址
export const addAddress = (data, header) => request({ method: 'POST', url: '/api/weapp/user/addAddress', identity: true, data, header });

//POST 编辑收货地址
export const editAddress = (data, header) => request({ method: 'POST', url: '/api/weapp/user/editAddress', identity: true, data, header });

//POST 删除收货地址
export const delAddress = (data, header) => request({ method: 'POST', url: '/api/weapp/user/delAddress', identity: true, data, header });

// 订单模块
//GET 获取订单 根据id
export const getOrderById = (data, header) => request({ method: 'GET', url: '/api/weapp/order/getOrderById', identity: true, data, header });

//GET 获取订单 根据status
export const getOrderByStatus = (data, header) => request({ method: 'GET', url: '/api/weapp/order/getOrderByStatus', identity: true, data, header });


//POST 添加订单
export const addOrder = (data, header) => request({ method: 'POST', url: '/api/weapp/order/addOrder', identity: true, data, header });

//POST 订单支付
//POST 订单支付 -- 付款
export const payOrder = (data, header) => request({ method: 'POST', url: '/api/weapp/order/payOrder', identity: true, data, header });

//POST 确认收货
export const receivedGoods = (data, header) => request({ method: 'POST', url: '/api/weapp/order/receivedGoods', identity: true, data, header });


//testGet2
export const testGet2 = (data, header) => request({ method: 'GET', url: '/test2', identity: true, data, header });

//tokenInvalid
export const tokenInvalid = (data, header) => request({ method: 'GET', url: '/api/weapp/user/test', identity: true, data, header });